<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>填写拒绝原因</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css" />
    <script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
    <script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.min.js"></script>
</head>
<body style="overflow:hidden;" scroll="no">
<t:formvalid formid="engineerRefusePlan" action="zyInspectionPlanController.do?doBatchEngineerRefusePlan" dialog="true"
             usePlugin="password" layout="table" tiptype="3" refresh="true" beforeSubmit="beforeSubmit">
    <input type="hidden" value="${planIds}" name="planIds" id="planIds"/>
    <input type="hidden" name="fileId" id="fileId"/>
    <table>
        <tr>
            <td style="width: 60px;">
                <label>拒绝原因:</label>
            </td>
            <td>
                <span><textarea name="remark" style="width: 410px;height: 170px;" datatype="*1-500" maxlength="500"
                                nullmsg="填写拒绝原因"></textarea></span>
            </td>
        </tr>
        <tr>
            <td align="right">
                <label class="Validform_label">附件：</label>
            </td>
            <td colspan="3" class="value">
                <input type="file" value="上传附件" id="remarkFileUpload2" onclick="chufa()"/>
                <span id="fileUploadname">
                        ${name}
                </span>
            </td>
        </tr>
    </table>
</t:formvalid>
</body>
<script type="text/javascript">

    $(function () {

        $("#remarkFileUpload2").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            fileTypeDesc: '文件格式:',
            queueID: 'instructionfile',
            fileTypeExts: '*.*',
            fileSizeLimit: '15MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: 'zyInspectionPlanController.do?remarkFileUploadView',
            onUploadSuccess: function (file, data) {
                var json = $.parseJSON(data).attributes;
                $("#fileUploadname").text(json.name);
                //alert("附件3id="+json.fileKey);
                $("#fileId").val(json.fileKey);
                tip("上传成功！");
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的" + $('#instruction').uploadify('settings', 'fileSizeLimit') + "大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
                ;
            }
        });
    });

    function beforeSubmit() {
        var flag = true;
        $.ajax({
            url: "zyInspectionPlanController.do?doJudgePlanOfEngineerRefusePlan",
            data: {
                "planIds": $("input[name='planIds']").val(),
                "type": "refuse"
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                }
            }
        });
        return flag;
    }
</script>